define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'dahui/smslog/index',
                    add_url: 'dahui/smslog/add',
                    edit_url: 'dahui/smslog/edit',
                    del_url: 'dahui/smslog/del',
                    multi_url: 'dahui/smslog/multi',
                    table: 'dahui_smslog',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'nianyue_id', title: __('Nianyue_id')},
                        {field: 'businesstype', title: __('Businesstype'), searchList: {"个税":__('个税'),"公积金":__('公积金'),"社保":__('社保'),"补充公积金":__('补充公积金')}, formatter: Table.api.formatter.normal},
                        {field: 'sendtype', title: __('Sendtype'), searchList: {"新办成功":__('新办成功'),"转出成功":__('转出成功')}, formatter: Table.api.formatter.normal},
                        {field: 'idnumber', title: __('Idnumber')},
                        {field: 'mobile', title: __('Mobile')},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'nianyue.id', title: __('Nianyue.id')},
                        {field: 'nianyue.businessnumber', title: __('Nianyue.businessnumber')},
                        {field: 'nianyue.paymentdate', title: __('Nianyue.paymentdate')},
                        {field: 'nianyue.payingcompany', title: __('Nianyue.payingcompany')},
                        {field: 'nianyue.paymentbase', title: __('Nianyue.paymentbase')},
                        {field: 'nianyue.paymentamount', title: __('Nianyue.paymentamount'), operate:'BETWEEN'},
                        {field: 'nianyue.earlytransfer', title: __('Nianyue.earlytransfer')},
                        {field: 'nianyue.newjoin_status', title: __('Nianyue.newjoin_status'), formatter: Table.api.formatter.status},
                        {field: 'nianyue.zc_status', title: __('Nianyue.zc_status'), formatter: Table.api.formatter.status},
                        {field: 'nianyue.refundornot', title: __('Nianyue.refundornot')},
                        {field: 'nianyue.taobaoname', title: __('Nianyue.taobaoname')},
                        {field: 'nianyue.create_time', title: __('Nianyue.create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'nianyue.update_time', title: __('Nianyue.update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'nianyue.luruman', title: __('Nianyue.luruman')},
                        {field: 'nianyue.auditman', title: __('Nianyue.auditman')},
                        {field: 'nianyue.opman', title: __('Nianyue.opman')},
                        {field: 'nianyue.dingdan_id', title: __('Nianyue.dingdan_id')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});